﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QxFramework.Core;
using GameControl;
using System;
public class BoxItem : PosFixedItem
{
    public BoxItemField NewSetting;
    public override ItemField ItemFieldSetting { get => NewSetting; set => NewSetting = value as BoxItemField; }
    public override void OnRealDestory()
    {
        base.OnRealDestory();
            List<string> dropName = GetField<BoxItemField>().DropItemName;
        if (dropName.Count !=0)
        {
            for(int i=0;i< dropName.Count; i++)
            {
                MessageManager.Instance.Get<GameMap.ItemMapEvent>().DispatchMessage(GameMap.ItemMapEvent.CreateInMap, this, new GameMap.ItemCreateArgs("CollectableItem", ItemFieldSetting.Position, (ItemField item) =>
                {
                    //强制转型后获取id
                    (item as CollectableItemField).CanCollectItemName = dropName[i];
                }));
            }
        }
    }
}
[System.Serializable]
public class BoxItemField :PosFixedItemField
{

    /// <summary>
    /// 敌兵死亡后掉落的物品,若未设置则不掉落
    /// </summary>
    public List<string> DropItemName = default;
}